package com.itheima_8;

import java.math.BigDecimal;
import java.util.Scanner;

public class test_8_1 {
    public static void main(String[] args) {
        Student s=new Student();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入姓名：");
        String s1 = sc.nextLine();
        s.setName("张三");
        while (true){
            System.out.println("请输入年龄：");
            String s2 = sc.nextLine();
            try {
                int i1 = Integer.parseInt(s2);
                s.setAge(i1);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
            }catch (RuntimeException e){
                System.out.println("请输入一个符合年龄范围的值18-100");
            }
        }
        System.out.println(s);
    }
}
